from getOhlcV_remote import getOhlcV_remote
import pandas as pd
from tqdm import tqdm

# 读取大数据集合
print("开始读取大数据集，请稍后")
df = pd.read_csv('/mnt/量化实习/mdl_6_36_0.csv', index_col=False)
print("数据读取完毕，开始遍历")

# 读取SecID
SecurityID_list = list(pd.DataFrame(df.SecurityID.value_counts()).index)

# 遍历SecID
for sec in tqdm(SecurityID_list):
    demo_df = df.loc[df['SecurityID'] == sec]
    try:  # 如果过程中出现错误，则将错误的个股数据输出
        democlass = getOhlcV_remote(r'/mnt/量化实习/', '/mnt/量化实习/测试数据.csv', 100, 'TradeVolume', 'percent')
        democlass.SecDatadf = demo_df.reset_index(drop=True)  # 传入数据集
        democlass.main_get()
    except:
        demo_df.to_csv('errorData.csv', index=False)
        break
